package Graphique;

import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Final extends JFrame implements ActionListener {
	private static final long serialVersionUID = 1L;
	private JButton quit;
	private JButton copier;

	public Final(String motDePasse) {
		super("Mot de passe Final");
		JLabel texte = new JLabel("Voici ton mot de passe : ");
		JLabel mdp = new JLabel(motDePasse);
		copier = new JButton("Je confirme");
		quit = new JButton("Je change");

		quit.addActionListener(this);

		GridBagLayout grid = new GridBagLayout();
		GridBagConstraints c;
		Container in = getContentPane();
		in.setLayout(grid);

		c = new GridBagConstraints();
		c.gridx = c.gridy = 0;
		c.gridheight = c.gridwidth = 1;
		c.anchor = GridBagConstraints.CENTER;
		c.weightx = c.weighty = 0;
		c.insets = new Insets(40, 50, 0, 0);
		grid.setConstraints(texte, c);
		in.add(texte);

		c = new GridBagConstraints();
		c.gridx = 1;
		c.gridy = 0;
		c.gridwidth = GridBagConstraints.REMAINDER;
		c.fill = GridBagConstraints.HORIZONTAL;
		c.anchor = GridBagConstraints.BASELINE;
		c.gridheight = GridBagConstraints.REMAINDER;
		c.weightx = c.weighty = 1;
		c.insets = new Insets(40, 20, 0, 20);
		grid.setConstraints(mdp, c);
		in.add(mdp);
		
		 c = new GridBagConstraints();
		 c.gridx = 0;
		 c.gridy = 2;
		 c.fill = GridBagConstraints.NONE;
		 c.gridwidth = GridBagConstraints.REMAINDER;
		 c.gridheight = GridBagConstraints.REMAINDER;
		 c.anchor = GridBagConstraints.CENTER;
		 c.weightx = c.weighty = 0;
		 c.insets = new Insets(0, 50, 0, 0);
		 grid.setConstraints(copier, c);
		 in.add(copier);

		c = new GridBagConstraints();
		c.gridx = 0;
		c.gridy = 2;
		c.fill = GridBagConstraints.NONE;
		c.anchor = GridBagConstraints.CENTER;
		c.weightx = c.weighty = 0;
		c.insets = new Insets(0, 20, 0, 0);
		grid.setConstraints(quit, c);
		in.add(quit);


		this.setLocationRelativeTo(null);
		this.setSize(400, 200);
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	// Fermer la fenetre lors du clique sur "Je change"  
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == quit) {
			this.setVisible(false);
		}
	}
}
